package site.template;

import site.tagtype.base.SimpleBaseTag;

public class SimpleSiteTemplate {
	// 各种属性
	private String[] keywords;
	// ....
	
	// 该模板的各种标签
	private SimpleBaseTag htmlTag;
	private SimpleBaseTag titleTag;
	private SimpleBaseTag headTag;
	private SimpleBaseTag bodyTag;
	private SimpleBaseTag tableTag;

	private void initTags() {
		htmlTag = new SimpleBaseTag("html");
		titleTag = new SimpleBaseTag("title");
		headTag = new SimpleBaseTag("head");
		bodyTag = new SimpleBaseTag("body");
		tableTag = new SimpleBaseTag("table");
		StringBuffer strBuf = new StringBuffer();
		// i行j列
		for (int i = 0; i < 3; i++) {
			strBuf.append("<tr>\n");
			for (int j = 0; j < 5; j++) {
				strBuf.append("\t<td>" + i * j + "</td>\n");
			}
			strBuf.append("</tr>\n");
		}
		tableTag.setDataString(strBuf.toString());

		// 配置各标签之间的关系
		htmlTag.addChild(headTag);
		htmlTag.addChild(bodyTag);
		headTag.addChild(titleTag);
		bodyTag.addChild(tableTag);

	}

	public String getHtml() {
		initTags();
		return htmlTag.getAllTagData();
	}

	public static void main(String[] args) {
		System.out.println(new SimpleSiteTemplate().getHtml());
	}
}
